//package com.example.game;
//
//import android.graphics.drawable.AnimatedStateListDrawable;
//import android.os.Bundle;
//import android.util.Log;
//import android.view.KeyEvent;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.webkit.WebSettings;
//import android.webkit.WebView;
//import android.webkit.WebViewClient;
//import android.widget.FrameLayout;
//
//import androidx.fragment.app.Fragment;
//
//public class setWebFragment extends Fragment {
//        private Bundle bundle;
//        private WebView webView;
//        private FrameLayout frameLayout;
//
//        @Override
//        public View onCreateView(LayoutInflater inflater, ViewGroup container,
//                                 Bundle savedInstanceState) {
//            View view = inflater.inflate(R.layout.web_fragment_layout, container, false);
//            super.onCreate(savedInstanceState);
//            frameLayout = findViewById(R.id.xwalk_view);
//            bundle = getIntent().getExtras();
//            initView();
//        }
//
//        private void initView() {
//            webView = new WebView(this);
//            WebSettings settings = webView.getSettings();
//            settings.setDomStorageEnabled(true);
//            //解决一些图片加载问题
//            settings.setJavaScriptEnabled(true);
//            settings.setBlockNetworkImage(false);
////            webView.setWebViewClient(new WebViewClient(){
////                @Override
////                public boolean shouldOverrideUrlLoading(WebView view, String url) {
////                    Log.d("webview","url: "+url);
////                    view.loadUrl(url);
////                    return true;
////                }
////            });
//            frameLayout.addView(webView);
//            String url = bundle.getString("URL");
//            webView.loadUrl(url);
//        }
//
//        //监听BACK按键，有可以返回的页面时返回页面
//        @Override
//        public boolean onKeyDown(int keyCode, KeyEvent event) {
//            if(keyCode == KeyEvent.KEYCODE_BACK) {
//                if(webView.canGoBack()) {
//                    webView.goBack();
//                    return true;
//                }
//            }
//
//            return super.onKeyDown(keyCode, event);
//        }
//
//        @Override
//        protected void onDestroy() {
//            if (webView != null) {
//                webView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
//                webView.setTag(null);
//                webView.clearHistory();
//
//                ((ViewGroup) webView.getParent()).removeView(webView);
//                webView.destroy();
//                webView = null;
//            }
//            super.onDestroy();
//        }
//    }
//}
